package com.tailyou.androidlearning202400.kl

// 定义一个函数getSum，接收一个整数参数number，计算1-number的偶数和
fun getSum(number: Int): Int {
    var sum = 0
    for (i in 1..number) {
        if (i % 2 == 0) {
            sum += i
        }
    }
    return sum
}

// 调用函数并打印结果
fun main() {
    val number = 6 // 计算1到6之间偶数的和
    val sum = getSum(number)
    println("The sum of even numbers from 1 to $number is: $sum")
}